package Cricle;

public class CircleApp {

    public static void main(String[] args) {
        double rd = 12.3;
        System.out.println("半径 = " + rd);

        Circle circle1 = new Circle(rd);
        double cir = circle1.calPerimeter();
        double area = circle1.calArea();

        System.out.println("周长：" + cir);
        System.out.println("面积：" + area);

        System.out.println("=================");
        // 2.
        Circle circle2 = new Circle(circle1);

        System.out.println("周长：" + circle2.calPerimeter());
        System.out.println("面积：" + circle2.calArea());
        System.out.println("半径：" + circle2.getRadius());

        System.out.println("=================");
        // 4. 不会修改半径
        circle1.setRadius(30);
        System.out.println(circle2.getRadius());


        System.out.println("=================");
        // 5.
        Circle circle3 = circle2;
        circle2.setRadius(20);
        System.out.println("周长：" + circle3.calPerimeter());
        System.out.println("面积：" + circle3.calArea());
        System.out.println("半径：" + circle3.getRadius());

        System.out.println(circle2 == circle3);
        System.out.println(circle1 == circle3);

        // circle2 赋值，不会影响circle3 指代的内容
        circle2 = null;
        System.out.println("周长：" + circle3.calPerimeter());
        System.out.println("面积：" + circle3.calArea());
        System.out.println("半径：" + circle3.getRadius());


        // 编译通过，但是运行时候出现空指针异常
        // Circle circle3 = null;
        // circle3 = new Circle(circle3);
    }
}


